package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.roo.addon.entity.RooIdentifier;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

/**
 * The Class TtlsbsfoPK.
 */
@Embeddable
@Configurable
@RooIdentifier(dbManaged = true)
public final class TtlsbsfoPK implements java.io.Serializable {

	/** The qnu numitem. */
	@Column(name = "QNU_NUMITEM",columnDefinition = "DECIMAL", nullable = false)
    private BigDecimal qnuNumitem;

	/** The cod idorden. */
	@Column(name = "COD_IDORDEN", nullable = false,columnDefinition = "CHAR", length = 8)
    private String codIdorden;

	/** The cod claseord. */
	@Column(name = "COD_CLASEORD", nullable = false,columnDefinition = "CHAR", length = 3)
    private String codClaseord;

	/** The cod cliecash. */
	@Column(name = "COD_CLIECASH", nullable = false,columnDefinition = "CHAR", length = 16)
    private String codCliecash;

	/**
	 * Instantiates a new ttlsbsfo pk.
	 *
	 * @param qnuNumitem the qnu numitem
	 * @param codIdorden the cod idorden
	 * @param codClaseord the cod claseord
	 * @param codCliecash the cod cliecash
	 */
	public TtlsbsfoPK(BigDecimal qnuNumitem, String codIdorden, String codClaseord, String codCliecash) {
        super();
        this.qnuNumitem = qnuNumitem;
        this.codIdorden = codIdorden;
        this.codClaseord = codClaseord;
        this.codCliecash = codCliecash;
    }

	/**
	 * Instantiates a new ttlsbsfo pk.
	 */
	@SuppressWarnings("unused")
	private TtlsbsfoPK() {
        super();
    }

	/**
	 * Gets the qnu numitem.
	 *
	 * @return the qnu numitem
	 */
	public BigDecimal getQnuNumitem() {
        return this.qnuNumitem;
    }

	/**
	 * Gets the cod idorden.
	 *
	 * @return the cod idorden
	 */
	public String getCodIdorden() {
        return this.codIdorden;
    }

	/**
	 * Gets the cod claseord.
	 *
	 * @return the cod claseord
	 */
	public String getCodClaseord() {
        return this.codClaseord;
    }

	/**
	 * Gets the cod cliecash.
	 *
	 * @return the cod cliecash
	 */
	public String getCodCliecash() {
        return this.codCliecash;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof TtlsbsfoPK)) return false;
        TtlsbsfoPK other = (TtlsbsfoPK) obj;
        if (qnuNumitem == null) {
            if (other.qnuNumitem != null) return false;
        } else if (!qnuNumitem.equals(other.qnuNumitem)) return false;
        if (codIdorden == null) {
            if (other.codIdorden != null) return false;
        } else if (!codIdorden.equals(other.codIdorden)) return false;
        if (codClaseord == null) {
            if (other.codClaseord != null) return false;
        } else if (!codClaseord.equals(other.codClaseord)) return false;
        if (codCliecash == null) {
            if (other.codCliecash != null) return false;
        } else if (!codCliecash.equals(other.codCliecash)) return false;
        return true;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
        final int prime = 31;
        int result = 17;
        result = prime * result + (qnuNumitem == null ? 0 : qnuNumitem.hashCode());
        result = prime * result + (codIdorden == null ? 0 : codIdorden.hashCode());
        result = prime * result + (codClaseord == null ? 0 : codClaseord.hashCode());
        result = prime * result + (codCliecash == null ? 0 : codCliecash.hashCode());
        return result;
    }

	/**
	 * To json.
	 *
	 * @return the string
	 */
	public String toJson() {
        return new JSONSerializer().exclude("*.class").serialize(this);
    }

	/**
	 * From json to ttlsbsfo pk.
	 *
	 * @param json the json
	 * @return the ttlsbsfo pk
	 */
	public static TtlsbsfoPK fromJsonToTtlsbsfoPK(String json) {
        return new JSONDeserializer<TtlsbsfoPK>().use(null, TtlsbsfoPK.class).deserialize(json);
    }

	/**
	 * To json array.
	 *
	 * @param collection the collection
	 * @return the string
	 */
	public static String toJsonArray(Collection<TtlsbsfoPK> collection) {
        return new JSONSerializer().exclude("*.class").serialize(collection);
    }

	/**
	 * From json array to ttlsbsfo p ks.
	 *
	 * @param json the json
	 * @return the collection
	 */
	public static Collection<TtlsbsfoPK> fromJsonArrayToTtlsbsfoPKs(String json) {
        return new JSONDeserializer<List<TtlsbsfoPK>>().use(null, ArrayList.class).use("values", TtlsbsfoPK.class).deserialize(json);
    }

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;
}
